/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package org.eclipsecon.dui.swtmodel.impl;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EDataType;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;

import org.eclipse.emf.ecore.impl.EFactoryImpl;

import org.eclipse.emf.ecore.plugin.EcorePlugin;

import org.eclipsecon.dui.swtmodel.*;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model <b>Factory</b>.
 * <!-- end-user-doc -->
 * @generated
 */
public class SwtmodelFactoryImpl extends EFactoryImpl implements SwtmodelFactory {
	/**
	 * Creates the default factory implementation.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public static SwtmodelFactory init() {
		try {
			SwtmodelFactory theSwtmodelFactory = (SwtmodelFactory)EPackage.Registry.INSTANCE.getEFactory("http://eclipsecon.org/2009/dui"); 
			if (theSwtmodelFactory != null) {
				return theSwtmodelFactory;
			}
		}
		catch (Exception exception) {
			EcorePlugin.INSTANCE.log(exception);
		}
		return new SwtmodelFactoryImpl();
	}

	/**
	 * Creates an instance of the factory.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public SwtmodelFactoryImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public EObject create(EClass eClass) {
		switch (eClass.getClassifierID()) {
			case SwtmodelPackage.MCOMPOSITE: return createMComposite();
			case SwtmodelPackage.MCOLOR: return createMColor();
			case SwtmodelPackage.MBUTTON: return createMButton();
			case SwtmodelPackage.MLABEL: return createMLabel();
			case SwtmodelPackage.MTEXT: return createMText();
			case SwtmodelPackage.MGRID_LAYOUT: return createMGridLayout();
			case SwtmodelPackage.MGRID_DATA: return createMGridData();
			case SwtmodelPackage.MACTION_HANDLER: return createMActionHandler();
			case SwtmodelPackage.MCOMBO: return createMCombo();
			case SwtmodelPackage.MFONT: return createMFont();
			case SwtmodelPackage.CONSTANT: return createConstant();
			case SwtmodelPackage.VARIABLE: return createVariable();
			case SwtmodelPackage.TEMPLATE: return createTemplate();
			case SwtmodelPackage.TEMPLATE_USAGE: return createTemplateUsage();
			case SwtmodelPackage.MMODEL: return createMModel();
			default:
				throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier");
		}
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object createFromString(EDataType eDataType, String initialValue) {
		switch (eDataType.getClassifierID()) {
			case SwtmodelPackage.MSWT:
				return createMSWTFromString(eDataType, initialValue);
			default:
				throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier");
		}
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String convertToString(EDataType eDataType, Object instanceValue) {
		switch (eDataType.getClassifierID()) {
			case SwtmodelPackage.MSWT:
				return convertMSWTToString(eDataType, instanceValue);
			default:
				throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier");
		}
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public MComposite createMComposite() {
		MCompositeImpl mComposite = new MCompositeImpl();
		return mComposite;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public MColor createMColor() {
		MColorImpl mColor = new MColorImpl();
		return mColor;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public MButton createMButton() {
		MButtonImpl mButton = new MButtonImpl();
		return mButton;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public MLabel createMLabel() {
		MLabelImpl mLabel = new MLabelImpl();
		return mLabel;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public MText createMText() {
		MTextImpl mText = new MTextImpl();
		return mText;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public MGridLayout createMGridLayout() {
		MGridLayoutImpl mGridLayout = new MGridLayoutImpl();
		return mGridLayout;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public MGridData createMGridData() {
		MGridDataImpl mGridData = new MGridDataImpl();
		return mGridData;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public MActionHandler createMActionHandler() {
		MActionHandlerImpl mActionHandler = new MActionHandlerImpl();
		return mActionHandler;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public MCombo createMCombo() {
		MComboImpl mCombo = new MComboImpl();
		return mCombo;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public MFont createMFont() {
		MFontImpl mFont = new MFontImpl();
		return mFont;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Constant createConstant() {
		ConstantImpl constant = new ConstantImpl();
		return constant;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Variable createVariable() {
		VariableImpl variable = new VariableImpl();
		return variable;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Template createTemplate() {
		TemplateImpl template = new TemplateImpl();
		return template;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public TemplateUsage createTemplateUsage() {
		TemplateUsageImpl templateUsage = new TemplateUsageImpl();
		return templateUsage;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public MModel createMModel() {
		MModelImpl mModel = new MModelImpl();
		return mModel;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public MSWT createMSWTFromString(EDataType eDataType, String initialValue) {
		MSWT result = MSWT.get(initialValue);
		if (result == null) throw new IllegalArgumentException("The value '" + initialValue + "' is not a valid enumerator of '" + eDataType.getName() + "'");
		return result;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String convertMSWTToString(EDataType eDataType, Object instanceValue) {
		return instanceValue == null ? null : instanceValue.toString();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public SwtmodelPackage getSwtmodelPackage() {
		return (SwtmodelPackage)getEPackage();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @deprecated
	 * @generated
	 */
	@Deprecated
	public static SwtmodelPackage getPackage() {
		return SwtmodelPackage.eINSTANCE;
	}

} //SwtmodelFactoryImpl
